package com.wxzz.elearing.pay.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wxzz.elearing.pay.entity.UserOrderStatisticsData;
import com.wxzz.elearing.pay.entity.UserTransaction;
import com.wxzz.elearing.pay.vo.SelectAllIncomePriceVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

public interface UserOrderStatisticsDataMapper extends BaseMapper<UserOrderStatisticsData> {

    @Select("SELECT\n" +
            "\tSUM( amount ) amount,SUM(order_num) orderNum \n" +
            "FROM\n" +
            "\t`user_order_statistics_data` \n" +
            "WHERE\n" +
            "\tdeleted = 0 \n" +
            "\tAND save_time BETWEEN #{startTime} \n" +
            "\tAND #{endTime}")
    SelectAllIncomePriceVo selectUserOrderStatisticsDataBySaveTime(@Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("SELECT\n" +
            "\tSUM( amount ) amount,SUM(order_num) orderNum \n" +
            "FROM\n" +
            "\t`user_order_statistics_data` \n" +
            "WHERE\n" +
            "\tdeleted = 0")
    SelectAllIncomePriceVo selectAllUserOrderStatisticsData();

    @Select("SELECT\n" +
            "\tSUM( amount )\n" +
            "FROM\n" +
            "\t`user_order_statistics_data` \n" +
            "WHERE\n" +
            "\tsave_time BETWEEN #{startTime} \n" +
            "\tAND #{endTime} \n" +
            "\tAND deleted = 0 \n" +
            "GROUP BY\n" +
            "\tsave_time \n" +
            "ORDER BY\n" +
            "\tsave_time DESC")
    List<BigDecimal> selectListAmount(@Param("startTime") String startTime, @Param("endTime") String endTime);


}
